package com.qf.controller;

import com.qf.pojo.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author 千锋健哥
 */
@RestController
@RequestMapping("/test")
@Api(value = "测试TestController接口")
public class TestController {

    //注入user1
    @Resource(name = "user1")
    private User user;

    //从yml文件中获取内容并给全局变量赋值
    @Value("${aliyun.ip}")
    private String ip;

    @Value("${aliyun.username}")
    private String username;

    @GetMapping("/hello")
    @ApiOperation(value = "测试hello")
    public String hello() {

        return "欢迎使用springboot测试";
    }

    /**
     * 测试初始化类的使用, 以及获取初始化的内容
     * @return
     */
    @GetMapping("/user")
    @ApiOperation(value = "测试初始化user用户接口")
    public User findValue() {

        return user;
    }

    @GetMapping("/test2")
    @ApiOperation(value = "测试查询配置文件属性内容")
    public String findUser() {

        return ip +"====" + username;
    }
}
